home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6162 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.ichange.com!newsmaster
  2. From: jshute@connect.reach.net (Jeff Shute)
  3. Newsgroups: comp.lang.c++
  4. Subject: What's so bad about global variables?
  5. Date: Sat, 10 Feb 1996 23:49:29 -0500
  6. Organization: The Lattan Empire Gift Shop
  7. Message-ID: <4fjtga$a8s@ias2.ichange.com>
  8. NNTP-Posting-Host: 204.50.58.65
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11.  
  12.  Why do programmers treat like global variables as if they are the
  13. single most evil thing you can possibly do in a C program?
  14.  
  15.  In reading through a programming book, I came across a program that
  16. needed to use random numbers.  Instead of just using the C library
  17. functions, they developed their own class for random numbers.  Their
  18. justification - srand and rand will result in the creation of a global
  19. variable, and all good programmers know that global variables must be
  20. avoided.
  21.  
  22.  To me, this seems a little silly.  I don't see what the problem is
  23. with global variables, especially when they can be hidden using
  24. static.  Is it really that important to avoid global variables?
  25.  
  26. ---
  27. Jeff Shute
  28. jshute@connect.reach.net
  29.  
  30.